package com.zztl.infiniteBand.presenter

import android.content.Context

import com.zztl.infiniteBand.base.BasePresenter
import com.zztl.infiniteBand.model.RanklistBean
import com.zztl.infiniteBand.net.FilterSubscriber
import com.zztl.infiniteBand.net.RetorfitServiceManger
import com.zztl.infiniteBand.net.converter.DataConverter
import com.zztl.infiniteBand.net.requestBean.RanklistRequest
import com.zztl.infiniteBand.ui.view.mvpview.RankingListView


/**
 * @desc
 * @auth ${user}
 * @time 2018/6/11  18:27
 */
class RankingPresenter : BasePresenter<RankingListView>() {


    fun getRanking(registerRequest: RanklistRequest, context: Context) {
        addSubscribe(RetorfitServiceManger
                .observe(RetorfitServiceManger.instance!!.apiService
                .getRankingList(DataConverter.instance.toJson(registerRequest)))
                .subscribe(object : FilterSubscriber<RanklistBean>(context) {

                    override fun success(bean: RanklistBean) {
                        view!!.getListSuccess(bean)
                        view!!.stopRefershOrLoad()
                    }

                    override fun fail() {
                        view!!.stopRefershOrLoad()
                    }

                }))
    }
}
